package com.inviscidlabs.schooled;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;

public class ActivitySemesterEdit extends FragmentActivity implements FragmentSemesterEdit.SemEditListener, DialogFragmentDefault.DefaultDialogResult{
	
	
	private DialogFragmentDefault dfd;
	private FragmentSemesterEdit fse;
//==================ONCREATE=============================
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_semesteredit);
			Log.i("Semester Activity Started", "true");
			fse = (FragmentSemesterEdit) getSupportFragmentManager().findFragmentById(R.id.fragment_semesterEdit);
			
		}
		
		
//===================ON CREATE ACTIONBAR===========================
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
	
			getMenuInflater().inflate(R.menu.activity_semesteredit,menu);
			return true;
	
	}
	
//====================ON MENU ITEM SELECTED============
	@Override
	  public boolean onOptionsItemSelected(MenuItem item) {
	    switch (item.getItemId()) {
	    
	    case R.id.menu_se_save:
	    	fse.saveSemester();
	    	this.setResult(RESULT_OK);
	    	finish();
	    	break;
	    
	    
	    }
	    return true;
	    
	}

//=============Interface from  FragmentSemesterEdit
		
//========Save was clicked, but the text box is null========
	@Override
	public void dialogNothingInSemField() {
		dfd= new DialogFragmentDefault(ActivitySemesterEdit.this, "Whoops!", "There doesn't seem to be anything in the Semester Name field. Enter a value, " +
				"even if it is asdasdafasde. We wouldn't recommend that, though."
				, "Ok", null, false);
		dfd.show(getSupportFragmentManager(), "Null Semester Dialog");
		
	
	
}


//=================Interface from DialogFragment========================

	//====Positive button selected======
	@Override
	public void positiveReturned() {
		dfd.dismiss();
	}
	
	
	
	//========Negative button not used, disregard=======
	@Override
	public void negativeReturned() {
		// TODO Auto-generated method stub
		
	}
		
//==================

}
